# !/usr/bin/env python
# encoding: utf-8


"""
  @author: gaogao
  @file: wafer.py
  @time: 2022/6/13 17:28
  @desc:
"""

from sqlalchemy import Column, Integer, String, DateTime
from database.base import Base
import datetime
from database.base_model import BaseModel
from sqlalchemy.orm import relationship
from database.entity.chip import Chip


class Wafer(Base.base, BaseModel):
    __tablename__ = 'wafer'
    # 指定id映射到id字段; id字段为整型，为主键,自增
    id = Column(Integer, primary_key=True, autoincrement=True)
    # wafer_name
    wafer_name = Column(String(50), unique=True)
    chip = relationship("Chip", order_by=Chip.id, back_populates="wafer")
    # shot的数量(指die的数量)
    shot_quantity = Column(String(10))
    # 芯片的数量(指subdie的数量)
    chip_quantity = Column(String(10))
    # 批次号
    lotID = Column(String(50))
    # oem代工厂家
    vendor = Column(String(50))
    # 温度
    temperature = Column(String(10))
    # 湿度
    humidity = Column(String(10))
    # 写入时间
    create_time = Column(DateTime, default=datetime.datetime.now())

    def __init__(self, wafer_name, shot_quantity, chip_quantity, lotID, vendor, temperature, humidity):
        self.wafer_name = wafer_name
        self.shot_quantity = shot_quantity
        self.chip_quantity = chip_quantity
        self.lotID = lotID
        self.vendor = vendor
        self.temperature = temperature
        self.humidity = humidity



    def __repr__(self):
        return "<Wafer(wafer_name='%s')>" % self.wafer_name


